<?php
class ConvertType {
    public static function objectToArray($object) {
        if (is_object($object)) {
            $object = (array) $object;
        }
        if(is_array($object)) {
            foreach ($object as $key => &$value) {
                $value = self::objectToArray($value);
            }
        }

        return $object;
    }
}